# import re
#
# from apps.spit.models import User
# from scf.settings.dev import logger
#
#
# def get_user_by_account(account, request):
# #     # 1.如果是后台用户是没有request对象的的
# #     if request is None:
# #         try:
# #             # 后台用户属于公司职员 is_staff = True
# #             user = User.objects.get(username=account, is_staff=True)
# #         except:
# #             return None
# #         return user
# #
# #     else:
#         try:
#             if re.match('^1[3456789]\d{9}$', account):
#                 # 手机号
#                 user = User.objects.get(mobile=account)
#             else:
#                 # 用户名
#                 user = User.objects.get(username=account)
#
#         except Exception as e:
#             logger.error(e)
#             return None
#         else:
#             return user
# #     # User.USERNAME_FIELD = 'mobile'
